<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>Title</title>
   <script type="text/javascript">
    
 var stationManager = function(){
    var treeFont = function(treeId, node) {
		return node.font ? node.font : {};
	}
    
    var initStationTree = function(treeId){
    	var stationTreeSetting = {
    			data: {
    				simpleData: {
    					enable: true
    				}
    			}
    		};
    	$.ajax({
			type : 'get',
			dataType : 'json',
			url : ctx + "/sys/station/list.do",
			contentType : 'charset=utf-8',
			success : function(msg) {
				var data = msg.roleData;
				$(data).each(function(i, n) {
					if (n.ROLE_TYPE==0) {
						n.icon = ctx + "/assets/img/btn/user.png";
					} else {
						n.icon = ctx + "/assets/img/btn/house.png";
					}
					
					n.name = n.ROLE_NAME;
					
				});
				var tree = $.fn.zTree.init($('#'+treeId), stationTreeSetting, data);
				tree.expandAll(true);
			}
		});
	}
    
    var initStationTree = function(treeId){
    	var stationTreeSetting = {
    			data: {
    				simpleData: {
    					enable: true
    				}
    			}
    		};
    	$.ajax({
			type : 'get',
			dataType : 'json',
			url : ctx + "/sys/station/list.do",
			contentType : 'charset=utf-8',
			success : function(msg) {
				var data = msg.roleData;
				$(data).each(function(i, n) {
					if (n.ROLE_TYPE==0) {
						n.icon = ctx + "/assets/img/btn/user.png";
					} else {
						n.icon = ctx + "/assets/img/btn/house.png";
					}
					
					n.name = n.ROLE_NAME;
					
				});
				var tree = $.fn.zTree.init($('#'+treeId), stationTreeSetting, data);
				tree.expandAll(true);
			}
		});
	}
    
    var initMenuTree = function(treeId){
    	var menuTreeSetting = {
    			check: {
    				enable: true
    			},
    			data: {
    				simpleData : {
    					enable : true,
    					idKey : "menuCode",
    					pIdKey : "parentCode",
    					rootPId : '0'
    				}
    			}
    		};
    	$.ajax({
			type : 'get',
			dataType : 'json',
			url : ctx + "/sys/station/sysmenu.do",
			contentType : 'charset=utf-8',
			success : function(msg) {
				var data = msg.menus;
				$(data).each(function(i, n) {
					if (n.menuType==0) {
						n.icon = ctx + "/assets/img/btn/user.png";
					} else {
						n.icon = ctx + "/assets/img/btn/house.png";
					}
					
					n.name = n.menuName;
					
				});
				var tree = $.fn.zTree.init($('#'+treeId), menuTreeSetting, data);
				tree.expandAll(true);
			}
		});
	}
    
    
    
    
    
    	return {
    		initStationTree:function(treeId){
    			return initStationTree(treeId);
    		},
    		initMenuTree:function(treeId){
    			return initMenuTree(treeId);
    		}
    	}
    }();
    
    
    
   
	    $(function(){
	    	
	    	stationManager.initStationTree('stationList');
	    	$('.chosen-select').chosen();
	    	
	    	$('#myModal').on('shown.bs.modal', function (e) {
	    		stationManager.initMenuTree('menuList');
	    	});
	    
	    });
	    
	    //显示选择菜单
	    function showSelectMenuList(){
	    	show_sys_modal('myModal');
	    }
	    
    </script>
</head>
<body>
<div class="content-wrapper">
    <h3>系统管理/岗位维护</h3>
    <div class="row">
    	<div class="col-lg-5">
	    	<div class="panel panel-info">
	    	<div class="panel-heading">
	    		<div class="text-left">
			          <em class="fa fa-users fa-2x">&nbsp;岗位菜单</em>
			       </div>
	    	</div>
	    		<div class="panel-body">
			       <ul id="stationList" class="ztree" style="height: 350px;"></ul>
			    </div>
	    	</div>
    	</div>
    	<div class="col-lg-7">
	    	<div class="panel panel-info">
	    	<div class="panel-heading">
	    		<div class="text-left">
			          <em class="fa fa-user fa-2x">&nbsp;岗位详情</em>
			       </div>
	    	</div>
	    		<div class="panel-body">
			        <form method="get" action="/" class="form-horizontal" style="height: 350px;">
						<div class="form-group">
                            <label class="col-sm-2 control-label">父级岗位:</label>
                            <div class="col-sm-10">
                       			 <input id="PARENT_NAME" name="PARENT_NAME" readonly="readonly" type="text" placeholder="" class="form-control">
                           		<input type="hidden" id="PARENT_CODE"  name="PARENT_CODE">
                           </div>
                        </div>
						<div class="form-group">
                            <label class="col-sm-2 control-label">类型:</label>
                            <div class="col-sm-10">
                                <select id="ROLE_TYPE" name="ROLE_TYPE" onchange="deptTypeSelectChange()"
                                		 class="form-control m-b chosen-select">
									<option value=''>请选择</option>
									<option value="1">岗位类别</option>
									<option value="0">岗位</option>
								</select>
                            </div>
                        </div>
                       <div class="form-group">
                            <label class="col-sm-2 control-label">岗位名称:</label>
                            <div class="col-sm-10">
                       			 <input id="ROLE_NAME" name="ROLE_NAME" type="text" placeholder="" class="form-control">
                           </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label">岗位职责描述:</label>
                            <div class="col-sm-10">
                       			 <input id="ROLE_DESC" name="ROLE_DESC" type="text" placeholder="" class="form-control">
                           </div>
                        </div>
                        <div class="form-group">
                           <label class="col-sm-2 control-label">岗位权限:</label>
                           <div class="col-sm-10">
                              <div class="input-group m-b">
                                 <input id="ROLE_MENU_NAME" name="ROLE_MENU_NAME" type="text" class="form-control">
                                 <input type="hidden" id="ROLE_MENU" name="ROLE_MENU">
                                  <span class="input-group-btn">
                                    <button type="button" onclick="showSelectMenuList()"
                                           class="btn ">选择</button>
                                 </span>
                              </div>
                           </div>
                        </div>
                          <p class="pull-right">
							<a id="btnAdd" type="button" class="btn btn-info" ><i class="fa fa-plus"></i>&nbsp;添加</a>
	               			<a id="btnDel" type="button" class="btn btn-danger" ><i class="fa fa-remove"></i>&nbsp;删除</a>
	               			 <a id="btnSave" onclick="editDeptEmp()" type="button" class="btn btn-success"><i class="fa fa-check"></i>&nbsp;保存</a>
						</p>
			        </form>
			    </div>
	    	</div>
    	</div>
    </div>
   
</div>
<div class="modal fade" id="myModal" data-backdrop="static">
  <div class="modal-dialog">
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
        <h4 class="modal-title">功能菜单</h4>
      </div>
      <div class="modal-body">
      <div>
      		<ul id="menuList" class="ztree" style="height: 350px;overflow-y: auto"></ul>
      </div>
       	
      </div>
      <div class="modal-footer">
        <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
        <button type="button" class="btn btn-primary">保存</button>
      </div>
    </div><!-- /.modal-content -->
  </div><!-- /.modal-dialog -->
</div>

 

   
</body>

</html>